function [MCMC] = mcmcsetup(Data,options)

%% this file sets up data structure for MCMC: latent variables, constraints, ...
MCMC.I = size(Data.ExPostFeasible,1);  %n applicants
MCMC.J = size(Data.ExPostFeasible,2);  %n programs
MCMC.R = size(Data.ChoiceIndexRank,2); %max list length
MCMC.year = Data.year;

%% program inds
MCMC.TypeIndex = Data.TypeIndex; %final column is program identifiers

%% enrollment, placement, graduation
enrollmentIndex = Data.enrollment;
enrollmentIndex(isnan(enrollmentIndex)) = 0;
MCMC.enrollmentIndex = enrollmentIndex;

placementIndex = nansum(Data.ApplicationsIndex.*Data.AssignedApp,2);
MCMC.placementIndex = placementIndex;

MCMC.grad6 = Data.grad6;
MCMC.grad6(isnan(Data.grad6)) = 0;

%% School preferences and slots
MCMC.seats = options.seats; %"true" seats
MCMC.sobrecupo = options.sobrecupo; %"capacity in initial match" = sobrecupo + seats
MCMC.exPostInferredSlots = options.slots; %NOTE: options.slots is obs. enrollment
%   sometimes equal to sobrecupo+seats, sometimes overadmit if people are tied.
%   don't use in 2012, only use if seats and sobrecupo are unavailable  
MCMC.Priorities = Data.Index; %programs' ranking of people
MCMC.EligibleToApply = Data.FeasibleAny; %indicator for eligible to apply to j, 0 if ruled out because don't meet some constraint
MCMC.Apps = Data.ApplicationsIndex; %raw apps, have not yet removed infeasible or irrelevant options.  Do this in Julia.
MCMC.AppsCalledWaitlist = Data.AppsCalledWaitlist; %(I,R) indicator for i was waitlisted at j_{ir} AND was above last person off of WL to enroll.
MCMC.platform = options.platform; %1 if on-platform
MCMC.FeasibleOff = full(Data.FeasibleOff);  %indicator for off-platform program was ex-post feasible based on 5% wl cutoff
MCMC.cutoff = options.punt_lastAdmit;
MCMC.wlcutoff = options.punt_last_waitAdmit;

%% matrices of X's (deterministic stuff) and Xrc's (multiply the RC's)
tic
[Type0,X_fixed,X_oo,X_rc,X_interact_i,X_interact_j,X_BVPdiscount_ij,X_dist_ij,~] = MCMCsetupMatrices(MCMC,Data);
MCMC.Type0 = Type0;
MCMC.X_rc = X_rc;
MCMC.X_fixed = X_fixed;
MCMC.X_oo = X_oo;
MCMC.X_interact_i = X_interact_i;
MCMC.X_interact_j = X_interact_j;
MCMC.X_discount_ij = X_BVPdiscount_ij;
MCMC.X_dist_ij = X_dist_ij;
MCMC.BVPj = Data.BVPj;
MCMC.AidAmount = Data.AidAmount(:,1);
MCMC.Scores = Data.Scores;
toc


end
